import store from './../store'

export default {
  install (app, options) {
    // TODO 通过权限控制按钮显示隐藏，思路代码，未完成及测试
    // 资源根据权限控制显示隐藏的自定义指令
    app.directive('has', {
      beforeMount: function (el, binding) {
        // 获取按钮权限
        const resourceList = store.getters.resourcesList
        if (binding.value) {
          if (resourceList === undefined || resourceList.indexOf(binding.value) === -1) {
            el.style.display = 'none'
          }
        }
      }
    })
  }
}
